<template>
  <div>
    <x-header :left-options="{backText: ''}" :title="$route.name"></x-header>
    <div class="gz-content">
      <div class="screen-box">
        <div class="search-input">
          <group style="margin: 0;">
            <x-input title="title" v-model="value" type="text" :readonly="initSearch" placeholder="请输入姓名、手机号、证件号进行查询"
              :debounce="500" @on-change="searchKey">
              <template slot="label">
                <div style="display: flex;align-items: center;justify-content: center;">
                  <x-icon type="ios-search-strong" size="20" style="margin-right: 10px;color: #979797"></x-icon>
                </div>
              </template>
            </x-input>
          </group>
        </div>

        <div class="screen-icon" @click="showModal = true">
          <!-- <img :src="require('@/assets/screen.svg')" style="width: inherit;" /> -->
        </div>
      </div>
      <!-- List -->
      <div class="list-box">
        <scroller ref="myscroll" :on-refresh="refresh" :on-infinite="infinite" :no-data-text="'暂无更多'"
          class="scroll-view" :height="scrollHeight">
          <div v-for="(task,tindex) in taskList" :key="tindex">
            <gz-list-card :content="task" @click="taskDispose"></gz-list-card>
          </div>
        </scroller>
      </div>
    </div>
    <screen-modals v-model="showModal" :statusList="searchParam.statusList" @search="searchTask"></screen-modals>
    <dispose-modals ref="disposeTaskModal" modalKey="fenpei" :modalData="disposeData" @dispose="taskConfirm"></dispose-modals>
  </div>
</template>

<script>
  import Vue from 'vue'
  import {
    gzListCard
  } from '@/components/customize'
  import {
    Tab,
    Tabs,
    Badge
  } from 'vant';
  import VueScroller from "vue-scroller";
  import screenModals from './screenModals.vue'
  import disposeModals from './disposeModals.vue';
  import publicFun from './publicFun'
  import {
    Dialog
  } from 'vant';
  Vue.use(VueScroller);
  export default {
    components: {
      gzListCard,
      [Tab.name]: Tab,
      [Tabs.name]: Tabs,
      [Badge.name]: Badge,
      screenModals,
      disposeModals
    },
    mixins: [publicFun],
    data() {
      return {
        active: 0,
        value: '',
        showModal: false,
        // pageStatus: '1,2,4',
        searchParam: {
          "eme.key_$VEQ": '',
          "statusList": '0',
          "supportMobile$V": true
        },
      }
    },
    mounted() {
      let searchParam = this.searchParam
      this.pageParams = {
        searchParam: searchParam,
        type: 'taskPool'
      }
      this.$nextTick(() => {
        this.getTaskList({
          searchParam: searchParam,
          type: 'taskPool'
        })
        if (this.active == 0) {
          this.$refs.myscroll.finishInfinite(true);
        } else {
          this.$refs.myscroll1.finishInfinite(true);
        }
      })
    },
    methods: {
      taskConfirm(data) {
        let requestData = {
          id: data.taskId,
          status: data.fpType.key == 'strong' ? 2 : 1,
          initiator_: data.role.userId,
          version: data.version
        }
        this.$toast.loading({
          message: '加载中...',
          duration: 0
        })
        let post = this.baseService.post(this.__ctx + '/taskPool/update', requestData)
        post.then(result => {
          this.$toast.clear()
          if (result.isOk) {
            this.showTaskMove = false
            this.$refs.abGrid.loadPageData();
            this.$toast.success(`分配成功！`);
          } else {
            this.$toast.fail(result.msg);
          }
        })
        post.catch(err => {
          this.$toast.clear()
          this.$toast.fail('分配失败');
        })
      },

      searchTask(params) {
        this.$refs.myscroll.finishInfinite(true);
        this.taskList = []
        this.pageParams = {
          searchParam: {
            ...this.searchParam,
            ...params
          },
          type: 'taskPool'
        }
        this.searchParam = {
          ...this.searchParam,
          ...params
        }
        this.getTaskList({
          searchParam: {
            ...this.searchParam,
            ...params
          },
          type: 'taskPool'
        })
      },

      searchKey(val) {
        this.initSearch = true
        this.$refs.myscroll.finishInfinite(true);
        this.taskList = []
        let searchParam = this.searchParam
        searchParam.key_ = val
        this.pageParams = {
          searchParam: searchParam,
          type: 'taskPool'
        }
        this.searchParam = searchParam
        this.getTaskList({
          searchParam: searchParam,
          type: 'taskPool'
        })
      }
    }
  }
</script>

<style lang="less" scoped>
  @import "./publicStyle.less";

</style>
